<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title>酷桃木</title>
    <!-- Bootstrap core CSS -->
    <link href="./static/css/bootstrap.min.css" rel="stylesheet">

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <link href="./static/css/ie10-viewport-bug-workaround.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="./static/css/dashboard.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="./static/js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script src="./static/js/jquery.min.js"></script>
    <script src="./static/js/fw4websocket.js"></script>
    <script type="application/javascript">
        function system_info() {
            parent.ws.send('monitor', "Hello World");
            parent.ws.message(function(evt) {
            	console.log(evt.data);
                var data = JSON.parse(evt.data);
                var newlist = template('template', {
                    results: data
                });
                console.log(newlist);
                $("#console").html(newlist);
            });
           setTimeout(system_info, 5000);
        }

        $(document).ready(function() {
            system_info();
        });

    </script>
</head>

<body style="padding: 0 0 0 0">
    <div>
        <div id="console-container">
            <div class="panel panel-default">
                <!-- Default panel contents -->
                <div class="panel-heading">各个节点负载监控</div>
                <!-- Table -->
                <table class="table">
                    <thead>
                        <tr>
                            <td>host</td>
                            <td>port</td>
                            <td>vm info</td>
                            <td>system load</td>
                            <td>cpu core</td>
                        </tr>
                    </thead>
                    <tbody id="console">
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="./static/js/jquery.min.js"></script>
    <script src="./static/js/bootstrap.min.js"></script>
    <!-- Just to make our placeholder images work. Don't actually copy the next line! -->
    <script src="./static/js/holder.min.js"></script>
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="./static/js/ie10-viewport-bug-workaround.js"></script>
    <script src="./static/js/template-native.js"></script>
    <script id="template" type="text/html">
        <?for(var i=0;i<results.data.length;i++){?>
        <tr>
            <td><?=results.data[i].host?></td>
            <td><?=results.data[i].port?></td>
            <td><?=results.data[i].runtimeInfo.vmInfo?></td>
            <td><?=results.data[i].runtimeInfo.sysLoadAverage?></td>
            <td><?=results.data[i].runtimeInfo.cpuCore?></td>
        </tr>
        <?}?>
    </script>
</body>

</html>
